local dismantlementSkill = fk.CreateSkill {
  name = "iberia__dismantlement_skill",
}

Fk:loadTranslationTable{
  ["iberia__dismantlement_skill"] = "过河拆桥",
  ["#iberia__dismantlement_skill"] = "选择一名区域内有牌的其他角色，你弃置其区域内的一张牌",
}

local I = require "packages/iberia/utility"

dismantlementSkill:addEffect("cardskill", {
  prompt = "#iberia__dismantlement_skill",
  target_num = 1,
  mod_target_filter = function(self, player, to_select, selected, card)
    return to_select ~= player and not to_select:isAllNude()
  end,
  target_filter = Util.CardTargetFilter,
  on_effect = function(self, room, effect)
    if effect.from.dead or effect.to.dead or effect.to:isAllNude() then return end
    local flag = "hej"

    if I.isCounsellor(effect.from) then
      local data = {}
      local areas = {"$Hand", "$Equip", "$Judge"}
      for e = 1, 3, 1 do
        if #effect.to:getCardIds(e) > 0 then
          table.insert(data, {areas[e], effect.to:getCardIds(e)})
        end
      end
      flag = { card_data = data }
    end

    local cid = room:askToChooseCard(effect.from, {
      target = effect.to,
      flag = flag,
      skill_name = "iberia__dismantlement"
    })
    room:throwCard({cid}, "iberia__dismantlement", effect.to, effect.from)
  end,
})

return dismantlementSkill
